// components/cart-item/cart-item.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: {
      type: Object,
      value: null,
      observer(newVal, oldVal, changedPath) {
        if (newVal) {
          this.initData(newVal);
        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    typeText: "", //类型
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //初始化数据
    initData: function(item) {
      //text
      var tmpText = '';
      if (item.type == 1) {
        tmpText = "拼团";
      } else if (item.type == 2) {
        tmpText = "限时";
      }
      this.setData({
        typeText: tmpText
      });
    },

    onMinus: function() {
      this.triggerEvent('minus', null, {});
    },
    onAdd: function() {
      this.triggerEvent('add', null, {});
    },
    onDelete: function() {
      this.triggerEvent('delete', null, {});
    }
  }
})